<?php

/*
 * 商品定时上架
 * @author birdy <freebirdy@foxmail.com>
 * @link http://www.aiyuangong.com
 */

namespace app\admin\command\cron;

use think\console\Input;
use think\console\Output;

class Onsale extends Cron
{
    protected $type = ['onsale', 1];
    protected $tips = '商品定时上架';

    //商品定时上架逻辑
    protected function executeLogic($data)
    {
        $commonid = [];
        foreach ($data as $data) {
            if ($data['exetime'] <= time() && $data['exeid'] > 0) {
                $commonid[] = $data['exeid'];
                $this->excuteids[] = $data['id'];
            }
        }

        if ($commonid) {
            $commonid = array_unique($commonid);
            $condition = [
                'id' => ['in', $commonid]
            ];
            Model('Common/Goods')->editProducesOnline($condition);
        }
    }

}
